<template>
  <div class="help-container">
    <div class="container">
      <div class="privacy-header-title">
        <div>Privacy & Cookie Policy</div>
        <div class="last-updated">Last Updated <strong>May 2025</strong></div>
      </div>
      <div class="privacy-content">
        <div v-for="(item, index) in privacyItems" :key="index" class="privacy-item">
          <div class="privacy-header" @click="toggleContent(index,item.key)">
            <h2>{{ item.title }}</h2>
            <span class="arrow" :class="{ 'arrow-up': openIndex === index }">
                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                  <path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
                </svg>
              </span>
          </div>
          <div class="privacy-body" v-show="openIndex === index">
            <div class="content" v-html="poem"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import HeaderTabs from '../../components/HeaderTabs/HeaderTabs.vue';
import { ref } from 'vue';
import { getAgreement } from '@/api/help';
const openIndex = ref<number | null>(null);
const poem = ref('')
const toggleContent = (index: number, key: string) => {
  poem.value = ''
  openIndex.value = openIndex.value === index ? null : index;
  getAgreement(key).then((res: any) => {
    poem.value = res.data;
  });
};

const privacyItems = ref([
  {
    key: 'introduction',
    title: 'Introduction',
    content: ``
       
  },
  {
    key: 'who_we_are',
    title: 'Who we are',
    content: ``
  },
  {
    key: 'your_rights',
    title: 'Your rights',
    content: ``
  },
  {
    key: 'the_lawful_bases_we_use_to_process_data',
    title: 'The lawful bases we use to process data',
    content: ``
  },
  {
    key: 'cookie_policy',
    title: 'Cookie Policy',
    content: ``
  },
  {
    key: 'the_data_we_collect_and_how_we_use_it',
    title: 'The Data we collect and how we use it',
    content: ``
  },
  {
    key: 'our_use_of_social_media',
    title: 'Our use of social media',
    content: ``
  },
  {
    key: 'how_long_we_keep_your_data_for',
    title: 'How long we keep your data for',
    content: ``
  },
  {
    key: 'third_parties_we_share_data_with_and_receive_data_from',
    title: 'Third Parties we share data with and receive data from',
    content: ``
  },
 
  {
    key: 'keeping_your_personal_data_secure',
    title: 'Keeping your personal data secure',
    content: ``
  },
  {
    key: 'third_party_apps_websites_and_services',
    title: 'Third party apps, websites and services',
   content: ``
  },
  {
    key: 'how_you_can_get_in_touch',
    title: 'How you can get in touch',
    content: ``
  }
]);
</script>

<style scoped lang="scss">
.help-container {
  width: 100%;
  min-height: 100vh;
  background-color: #fff;
  padding: 20px 0;
  margin: 0 auto;
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;

  @media (max-width: 1280px) {
    padding: 0 15px;
    width: 100%;
  }
}
.privacy-header-title {
  border-bottom: 1px solid #e0e0e0;
  font-size:24px;
  color:#525252;
  text-align: center;
  letter-spacing: 0.4px;
  font-weight: 400;
  padding-bottom:20px;
  .last-updated{
    font-size:13px;
    margin-top:20px;
  }
}
.privacy-content {
  max-width: 100%px;
  margin: 0 auto;
}

.privacy-item {
  border-bottom: 1px solid #e0e0e0;
  &:last-child {
    border-bottom: none;
  }
}

.privacy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  color:#525252;
  cursor: pointer;

  h2 {
    font-size: 20px;
    font-weight: 400;
    margin: 0;
    color: #525252;
    letter-spacing: 0.8px;
  }

  .arrow {
    transition: transform 0.3s ease;
    color: #666;

    &.arrow-up {
      transform: rotate(180deg);
    }
  }

  &:hover {
    h2 {
      color: #525252;
    }
    .arrow {
      color: #525252;
    }
  }
}
.privacy-header {
  text-align: center;
  // margin-bottom: 40px;

  height: 90px;
  h1 {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;

    @media (max-width: 1280px) {
      font-size: 24px;
    }
  }

  .last-updated {
    font-size: 16px;
    color: #666;

    @media (max-width: 1280px) {
      font-size: 14px;
    }
  }
}
.privacy-body {
  padding-bottom: 20px;

  .content {
    color: #666;
    font-size: 14px;
    line-height: 1.6;

    p {
      margin-bottom: 15px;

      &:last-child {
        margin-bottom: 0;
      }
    }
  }
}
</style>
